package com.juns.server.controller;

import com.juns.server.baen.User;
import com.juns.server.dto.RspResult;
import com.juns.server.service.UserService;
import com.juns.server.utils.key.RSAUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wjunjie
 * @version 1.0
 * @E-mail wang_junjie007@163.com
 * @company ZZYD
 * @createTime 2018/8/2 10:24
 * @类注释:
 */
@RestController
public class UserController {
    @Autowired
    private UserService userService;
    /**
     * get请求注解
     * @return
     */
    @GetMapping(value = "/findall")
    public RspResult<User> findAll(){
        RspResult<User> all = userService.findAll();
        return all;
    }

    @PostMapping(value = "/rse")
    public User test(@RequestParam String nn){
        try {
            System.out.println(nn);
            System.out.println(RSAUtils.decryptByPrivateKey(nn));
            User user = new User();
            user.setName(RSAUtils.encryptByPrivateKeyy("123321"));

            return user;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }
}
